package net.wanho.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.http.HttpStatus;

import java.io.Serializable;

/**
 * Author：汤小洋
 * Date：2023-07-05 15:27
 * Description：<描述>
 */
@ApiModel(value = "AjaxResult对象", description = "响应结果类")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AjaxResult implements Serializable {
    @ApiModelProperty(value = "响应状态码")
    private Integer status;

    @ApiModelProperty(value = "响应消息")
    private String msg;

    @ApiModelProperty(value = "响应数据")
    private Object data;

    public static AjaxResult success(){
        return new AjaxResult(HttpStatus.OK.value(), "success",null);
    }

    public static AjaxResult success(Object data){
        return new AjaxResult(HttpStatus.OK.value(),"success",data);
    }

    public static AjaxResult success(String msg,Object data){
        return new AjaxResult(HttpStatus.OK.value(),msg,data);
    }

    public static AjaxResult success(int status,String msg,Object data){
        return new AjaxResult(status,msg,data);
    }

    public static AjaxResult error(String msg){
        return new AjaxResult(HttpStatus.INTERNAL_SERVER_ERROR.value(), msg,null);
    }

    public static AjaxResult error(int status, String msg){
        return new AjaxResult(status,msg,null);
    }
}
